﻿using System;
using System.ServiceModel;
using System.Xml.Serialization;
using System.Runtime.Serialization;

[DataContract(Namespace = "")]
public class RobotJointsValues
{    

    public RobotJointsValues()
    {
        // TODO: Complete member initialization
    }
    [DataMember]     public int joint1 { get; set; }
    [DataMember]     public int joint2 { get; set; }
    [DataMember]     public int joint3 { get; set; }
    [DataMember]    public int joint4 { get; set; }
    [DataMember]    public int joint5 { get; set; }
    [DataMember]    public int joint6 { get; set; }

    public void setJoint(int j, int value)
    {
        switch (j)
        {
            case 1:
                joint1 = value;
                break;
            case 2:
                joint2 = value;
                break;
            case 3:
                joint3 = value;
                break;
            case 4:
                joint4 = value;
                break;
            case 5:
                joint5 = value;
                break;
            case 6:
                joint6 = value;
                break;
            default:
                RobotException re = new RobotException("Joint number " + j + " does not exist");
                throw (re) ;
        }
    }

    public int getJoint(int j)
    {
        switch (j)
        {
            case 1:
                return joint1;                
            case 2:
                return joint2;                
            case 3:
                return joint3;                
            case 4:
                return joint4;                
            case 5:
                return joint5;                
            case 6:
                return joint6;                
            default:
                RobotException re = new RobotException("Joint number " + j + " does not exist");
                throw (re);
        }
    }
    public RobotJointsValues(int j1, int j2, int j3, int j4, int j5, int j6)
    {        
        this.joint1 = j1;
        this.joint2 = j2;
        this.joint3 = j3;
        this.joint4 = j4;
        this.joint5 = j5;
        this.joint6 = j6;
    }

    public RobotJointsValues(string j1, string j2, string j3, string j4, string j5, string j6)
        : this(Convert.ToInt32(j1), Convert.ToInt32(j2), Convert.ToInt32(j3), Convert.ToInt32(j4), Convert.ToInt32(j5), Convert.ToInt32(j6))
    {
    }


    internal double getJoint(short j)
    {
        switch (j)
        {
            case 1:
                return Convert.ToDouble(joint1);
            case 2:
                return Convert.ToDouble(joint2);
            case 3:
                return Convert.ToDouble(joint3);
            case 4:
                return Convert.ToDouble(joint4);
            case 5:
                return Convert.ToDouble(joint5);
            case 6:
                return Convert.ToDouble(joint6);
            default:
                RobotException re = new RobotException("Joint number " + j + " does not exist");
                throw (re);
        }
    }    
}